<?php
// +----------------------------------------------------------------------
// | url模型
// +----------------------------------------------------------------------

class url_model {

	protected $url = array();


	public function  __construct() {
		$this->url = C('url');
	}


	//获取分类url
	public function category($id){
		if(!is_numeric($id))  $id = $id['id'];
		return $this->url['www'].M('category')->getNode($id,'url');
	}

	//获取字母页url
	public function letter($id){
		return $this->url['www'].'/glossary/'.strtolower($id).'/';
	}

	//获取图片页url
	public function view($id){
		$arr = $id;
		if(is_numeric($id)){
			$arr = M('image')->field('id,name')->where("id = '$id'")->find();
		}
		return $this->url['www'].'/'.name2dir($arr['name']).'-'.$arr['id'].'.html';

	}

	//获取图片下载页url
	public function download($id){
		$arr = $id;
		if(is_numeric($id)){
			$arr = M('image')->field('id,name')->where("id = '$id'")->find();
		}
		return $this->url['www'].'/'.name2dir($arr['name']).'-download-'.$arr['id'].'.html';
	}

	//获取关键字url
	public function keyword($name){
		$name = str_replace('/', ' ', $name);
		$name = urlencode($name);
		return $this->url['www'].'/s/'.$name.'/';
	}
	

}